package com.comilffo.app.controller;

import com.comilffo.app.model.HibernateOneroomDao;
import com.comilffo.app.model.Oneroom;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.AbstractController;



import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * Created by IntelliJ IDEA.
 * User: Mykyta.Demeshchenko
 * Date: 18.10.2010
 * Time: 17:15:40
 */
@Controller
public class HomePageController{

    private HibernateOneroomDao hibernateOneroomDao;
    private List<java.lang.String> someList;
    private List<Oneroom> onerooms;

    @Autowired
    public HomePageController(HibernateOneroomDao dao){
        this.hibernateOneroomDao = dao; 
    }

    public void setHibernateOneroomDao(HibernateOneroomDao dao){
        this.hibernateOneroomDao = dao;
    }

    @RequestMapping("/home")
    public ModelAndView helloWorld() {
        ModelAndView mav = new ModelAndView();
        mav.setViewName("home");
        //HibernateOneroomDao dao =
        mav.addObject("onerooms", hibernateOneroomDao.getAllOnerooms());
        return mav;
    } 

//    @RequestMapping(method= RequestMethod.GET)
//	public String getView(@PathVariable Long id, Model model) {
//        onerooms = hibernateOneroomDao.getAllOnerooms();
//        //
//		model.addAttribute(onerooms);
//		return "home";
//	}

//    @Override
//    protected ModelAndView handleRequestInternal(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception {
//        return new ModelAndView("home", "onerooms", );
//    }
}
